
Import('check_env', 'crc32c_cppflags')

env = check_env.Clone()

# Include paths
env.Append(CPPPATH = Split('''
                              #
                              #/galerautils/src
                              #/common
                           '''))

env.Prepend(LIBS=File('#/galerautils/src/libgalerautils.a'))
env.Prepend(LIBS=File('#/galerautils/src/libgalerautils++.a'))

gu_tests_srcs = Split('''
                        gu_tests.c
                        gu_mem_test.c
                        gu_bswap_test.c
                        gu_fnv_test.c
                        gu_mmh3_test.c
                        gu_spooky_test.c
                        gu_hash_test.c
                        gu_time_test.c
                        gu_fifo_test.c
                        gu_uuid_test.c
                        gu_dbug_test.c
                        gu_lock_step_test.c
                        gu_str_test.c
                        gu_utils_test.c
                      ''')

gu_tests_objs = env.SharedObject(gu_tests_srcs)

# Need to specify dedicated preprocessor macro for CRC32C unit test only
crc32c_env = env.Clone()
crc32c_env.Append(CPPFLAGS = crc32c_cppflags)
crc32c_objs = crc32c_env.SharedObject(['gu_crc32c_test.c'])

gu_tests = env.Program(target = 'gu_tests',
                       source = gu_tests_objs + crc32c_objs)

env.Test("gu_tests.passed", gu_tests)
env.Alias("test", "gu_tests.passed")

Clean(gu_tests, '#/gu_tests.log')

gu_testspp = env.Program(target = 'gu_tests++',
                         source = Split('''
                              gu_atomic_test.cpp
                              gu_vector_test.cpp
                              gu_string_test.cpp
                              gu_vlq_test.cpp
                              gu_digest_test.cpp
                              gu_mem_pool_test.cpp
                              gu_alloc_test.cpp
                              gu_rset_test.cpp
                              gu_string_utils_test.cpp
                              gu_uri_test.cpp
                              gu_config_test.cpp
                              gu_net_test.cpp
                              gu_datetime_test.cpp
                              gu_histogram_test.cpp
                              gu_stats_test.cpp
                              gu_thread_test.cpp
                              gu_asio_test.cpp
                              gu_deqmap_test.cpp
                              gu_tests++.cpp
                           '''))

env.Test("gu_tests++.passed", gu_testspp)
env.Alias("test", "gu_tests++.passed")

Clean(gu_testspp, '#/gu_tests++.log')

gu_to_test = env.Program(target = 'gu_to_test',
                         source = Split('''
                             gu_to_test.c
                         '''))
avalanche = env.Program(target = 'avalanche',
                         source = Split('''
                             avalanche.c
                         '''))
Import('all_tests')
if all_tests:
    env.Test("gu_to_test.passed", gu_to_test)
    env.Test("avalanche.passed", avalanche)

# copy_vs_assignment = env.Program(target = 'copy_vs_assignment',
#                         source = Split('''
#                             copy_vs_assignment.cpp
#                         '''))

deqmap_bench = env.Program(target = 'deqmap_bench',
                           source = Split('''
                               deqmap_bench.cpp
                           '''))

crc32c_bench = crc32c_env.Program(target = 'crc32c_bench',
                                  source = Split('''
                                      crc32c_bench.cpp
                                  '''))
